package cn.youqu.happy.module.youqu.dal.mysql.userFollows;

import cn.youqu.happy.framework.common.pojo.PageResult;
import cn.youqu.happy.framework.mybatis.core.mapper.BaseMapperX;
import cn.youqu.happy.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.youqu.happy.module.youqu.controller.admin.userFollows.vo.UserFollowsExportReqVO;
import cn.youqu.happy.module.youqu.controller.admin.userFollows.vo.UserFollowsPageReqVO;
import cn.youqu.happy.module.youqu.dal.dataobject.userFollows.UserFollowsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户关注 Mapper
 *
 * @author 王其岩  20112001045
 */
@Mapper
public interface UserFollowsMapper extends BaseMapperX<UserFollowsDO> {
    UserFollowsDO findByIdAndUid(@Param("id") Integer id, @Param("uid") Long uid);

    UserFollowsDO findOneBySysActivityIdAndUid(@Param("sysActivityId") Integer sysActivityId, @Param("uid") Long uid);


    default PageResult<UserFollowsDO> selectPage(UserFollowsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserFollowsDO>()
                .eqIfPresent(UserFollowsDO::getUid, reqVO.getUid())
                .eqIfPresent(UserFollowsDO::getSysActivityId, reqVO.getSysActivityId())
                .betweenIfPresent(UserFollowsDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(UserFollowsDO::getRemark, reqVO.getRemark())
                .orderByDesc(UserFollowsDO::getId));
    }

    default List<UserFollowsDO> selectList(UserFollowsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserFollowsDO>()
                .eqIfPresent(UserFollowsDO::getUid, reqVO.getUid())
                .eqIfPresent(UserFollowsDO::getSysActivityId, reqVO.getSysActivityId())
                .betweenIfPresent(UserFollowsDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(UserFollowsDO::getRemark, reqVO.getRemark())
                .orderByDesc(UserFollowsDO::getId));
    }

}
